package testcase.doctor;

import common.Host;
import common.TestData;
import org.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import api.doctor.GetActiveSubjectInfo;
/**
 * 医生端-获取聊天列表getActiveSubjectInfo接口测试用例
 * @author lyn
 */
public class TestGetActiveSubjectInfo
{
	/**
	 * 医生端-获取聊天列表getActiveSubjectInfo接口测试环境数据驱动
	 * @return 测试数据
	 * @throws Exception
	 */
	@DataProvider (name = "Test")
	public static String[][] testGetActiveSubjectInfoDataProvider() throws Exception
	{
		Host.setup("Test");
		TestData td = new TestData("doctor/TestGetActiveSubjectInfo.xml");
		return td.getParam();	
	}
	
	/**
	 * 医生端-获取聊天列表getActiveSubjectInfo接口
	 * @param caseName - 用例名称
	 * @param ResponsorID - 医生ID
	 * @return 接口返回数据
	 * @throws Exception
	 */
	@Test (dataProvider = "Test", groups = {"Test"})
	public void testGetActiveSubjectInfoTestCase(String caseName, String ResponsorID,String token) throws Exception
	{

		//调用接口并将接口返回数据转换成json格式
		
		String result = GetActiveSubjectInfo.options(ResponsorID,token);	
		JSONObject jsonResult;
		if (result==null || result.isEmpty())
		{
			jsonResult = null;
		}
		else
		{
			jsonResult = new JSONObject(result);
		}
		//设置检查点
				switch (caseName)
				{
				case "Success":
				Assert.assertEquals(jsonResult.getString("Data").isEmpty(), false);	//接口返回Data字段是否为空				
				break;
				case "NoResponsorID":
				Assert.assertNull(jsonResult); // 接口返回数据是否为空						
				break;
				}
	}
}